package com.lw.utils;

import com.lw.obj.GameObj;

import java.awt.*;

/**
 * 游戏工具类
 */
public class GameUtils {

    //关卡
    public static int level = 1;
    public static final int MAX_LEVEL = 3;//最大关卡数
    public static int SPEED = 200;//蛇运动速度
    public static int COMPLETE_SCORE = 10;//通关分数

    //蛇头， 上下左右方向
    public static Image upImg = Toolkit.getDefaultToolkit().getImage("img/up.png");
    public static Image downImg = Toolkit.getDefaultToolkit().getImage("img/down.png");
    public static Image leftImg = Toolkit.getDefaultToolkit().getImage("img/left.png");
    public static Image rightImg = Toolkit.getDefaultToolkit().getImage("img/right.png");

    //蛇身
    public static Image bodyImg = Toolkit.getDefaultToolkit().getImage("img/body.png");

    //食物
    public static Image foodImg = Toolkit.getDefaultToolkit().getImage("img/food.png");

    /**
     * 绘制文字
     */
    public static void drawWord(Graphics g,String str,Color color,int size,int x,int y){
        g.setColor(color);
        g.setFont(new Font("仿宋",Font.BOLD,size));//设置字体、粗体、字号
        g.drawString(str,x,y);
    }

    /**
     * 判断是否发生碰撞
     * @return
     */
    public static boolean isCollision(GameObj gameObj, GameObj gameObj2){
        if(gameObj.getX()==gameObj2.getX()&&gameObj.getY()==gameObj2.getY()){
            return true;
        }
        return false;
    }

}
